package com.lixl.concurrent;

public class ThreadMethodExplain {

	public static void main(String[] args) throws InterruptedException {

		ThreadMethodExplain.SubThread st = new ThreadMethodExplain.SubThread();
		System.out.println(st.getName()+"\t"+st.getState().name());
		
		ThreadMethodExplain.SubThread st0 = new ThreadMethodExplain.SubThread();
		System.out.println(st0.getName()+"\t"+st0.getState().name());
		st.start();
		st0.start();
		
		while(true){
			System.out.println(st.getName()+"\t"+st.getState().name());
			System.out.println(st0.getName()+"\t"+st0.getState().name());
			Thread.sleep(1000);
		}
	}
	
	public synchronized static void execMethod(){
		while(true){
			///do something
			//System.out.println(this.getState());
		}
	}
	
	static class SubThread extends Thread{
		@Override
		public void run() {
			ThreadMethodExplain.execMethod();
		}
	}

}
